﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.Data;
using System.Net;
using System.ServiceModel.Syndication;

namespace NET.Library.XML
{
    public class Atom
    {
        public static SyndicationFeed GetAtomFeed(string atomFeedURL)
        {
            //Get a web reponse from the RSS site
            WebRequest request = WebRequest.Create(atomFeedURL);
            WebResponse response = request.GetResponse();

            SyndicationFeed feed = null;

            //Load response into an XML document
            //XmlDocument doc = new XmlDocument();
            //doc.Load(response.GetResponseStream());

            XmlReader responseReader = XmlReader.Create(response.GetResponseStream());
            try
            {
                if (responseReader != null)
                {
                    feed = SyndicationFeed.Load(responseReader);
                }
            }
            finally
            {
                responseReader.Close();
                responseReader = null;
                response.Close();
                response = null;
                request = null;

            }

            return feed;

            //return doc;
        }
    }
}
